////
////  Utils.m
////  小宝爱学
////
////  Created by imac on 15-8-13.
////  Copyright (c) 2015年 imac. All rights reserved.
////
//
//#import "Utils.h"
//#import "Public.h"
//#import <SystemConfiguration/CaptiveNetwork.h>
//
//                
//
//@implementation Utils
//
//+ (NSString *)getMenid{
//    
//    NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
//    NSString *memid = [ud objectForKey:@"mem_id"];
//    return memid;
//}
//
//+ (NSString *)logeString:(NSInteger )code{
//    switch (code) {
//        case 4331:return @"手机号已被注册";break;
//            case 4302:return @"密码错误";break;
//            case 4301:return @"用户不存在";break;
//            case 4012:return @"密码长度须要>=6位数或字母";break;
//            case 4361:return @"元宝余额不足,快用支付宝";break;
//
//            
//        default:
//            return @"哈哈";
//            break;
//    }
//}
//
//+ (NSString *)getIOSVersion{
//    
//    return [[UIDevice currentDevice] systemVersion];
//}
//+ (NSString *)getBSSID{
//    
//    NSString *ssid = @"Not Found";
//    NSString *macIp = @"Not Found";
//    CFArrayRef myArray = CNCopySupportedInterfaces();
//    if (myArray != nil) {
//        CFDictionaryRef myDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));
//        if (myDict != nil) {
//            NSDictionary *dict = (NSDictionary*)CFBridgingRelease(myDict);
//            
//            ssid = [dict valueForKey:@"SSID"];
//            macIp = [dict valueForKey:@"BSSID"];
//        }
//    }
//    return macIp;
//}
//+ (NSString *)getSSID{
//    
//    NSString *ssid = @"Not Found";
//    NSString *macIp = @"Not Found";
//    CFArrayRef myArray = CNCopySupportedInterfaces();
//    if (myArray != nil) {
//        CFDictionaryRef myDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));
//        if (myDict != nil) {
//            NSDictionary *dict = (NSDictionary*)CFBridgingRelease(myDict);
//            
//            ssid = [dict valueForKey:@"SSID"];
//            macIp = [dict valueForKey:@"BSSID"];
//        }
//    }
//    return ssid;
//}
//
//+ (NSString*)getUUID{
//    
//    CFUUIDRef puuid = CFUUIDCreate( nil );
//    CFStringRef uuidString = CFUUIDCreateString( nil, puuid );
//    NSString * result = (NSString *)CFBridgingRelease(CFStringCreateCopy( NULL, uuidString));
//    CFRelease(puuid);
//    CFRelease(uuidString);
//    return result;
//}
//
////+ (NSString *)getIDFV{
////    
////    return [[[UIDevice currentDevice] identifierForVendor] UUIDString];
////}
//
////+ (NSString *)getIDFA{
////    
////    return [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
////}
//
//+ (NSString *)getIPAddress {
//    
//    NSString *address = @"error";
//    struct ifaddrs *interfaces = NULL;
//    struct ifaddrs *temp_addr = NULL;
//    int success = 0;
//    // retrieve the current interfaces - returns 0 on success
//    success = getifaddrs(&interfaces);
//    if (success == 0) {
//        // Loop through linked list of interfaces
//        temp_addr = interfaces;
//        while(temp_addr != NULL) {
//            if(temp_addr->ifa_addr->sa_family == AF_INET) {
//                // Check if interface is en0 which is the wifi connection on the iPhone
//                if([[NSString stringWithUTF8String:temp_addr->ifa_name] isEqualToString:@"en0"]) {
//                    // Get NSString from C String
//                    address = [NSString stringWithUTF8String:inet_ntoa(((struct sockaddr_in *)temp_addr->ifa_addr)->sin_addr)];
//                }
//            }
//            temp_addr = temp_addr->ifa_next;
//        }
//    }
//    // Free memory
//    freeifaddrs(interfaces);
//    return address;
//}
//
//+(CGSize)getSizeByText:(NSString*)text andFontSize:(CGFloat)fontSize andMaxSize:(CGSize)maxSize{
//    NSDictionary *dic=@{NSFontAttributeName:MFont(fontSize)};
//    CGSize size=[text boundingRectWithSize:maxSize options:NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:dic context:nil].size;
//    return size;
//}
//
//+(NSString *)getCurrentDate{
//    NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];
//    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
//    NSString *str = [dateFormatter stringFromDate:[NSDate date]];
//    return str;
//}
//
//+(NSString *)getCurrentYear{
//    NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];
//    [dateFormatter setDateFormat:@"yyyy"];
//    NSString *str = [dateFormatter stringFromDate:[NSDate date]];
//    return str;
//}
//+(NSString *)getCurrentMonth{
//    NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];
//    [dateFormatter setDateFormat:@"M"];
//    NSString *str = [dateFormatter stringFromDate:[NSDate date]];
//    return str;
//}
//+(NSString *)getCurrentDay{
//    NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];
//    [dateFormatter setDateFormat:@"d"];
//    NSString *str = [dateFormatter stringFromDate:[NSDate date]];
//    return str;
//}
//+(NSString *)getCurrentShi{
//    NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];
//    [dateFormatter setDateFormat:@"H"];
//    NSString *str = [dateFormatter stringFromDate:[NSDate date]];
//    return str;
//}
//+(NSString *)getCurrentFen{
//    NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];
//    [dateFormatter setDateFormat:@"m"];
//    NSString *str = [dateFormatter stringFromDate:[NSDate date]];
//    return str;
//}
//
//
//+(NSString *)createMD5:(NSString *)signString{
//    
//    const char*cStr =[signString UTF8String];
//    unsigned char result[16];
//    CC_MD5(cStr, (uint32_t)strlen(cStr), result);
//    return[NSString stringWithFormat:
//           @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
//           result[0], result[1], result[2], result[3],
//           result[4], result[5], result[6], result[7],
//           result[8], result[9], result[10], result[11],
//           result[12], result[13], result[14], result[15]
//           ];
//}
//
//+(NSString *)getStandardTimeWithInteger:(NSInteger )time{
//    
//    NSDate *date = [NSDate dateWithTimeIntervalSince1970:time];
//    NSDateFormatter *matter = [[NSDateFormatter alloc] init];
//    [matter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
//    NSString *string = [matter stringFromDate:date];
//    return string;
//}
//
//
//+(NSString *)timeDateWithInteger:(NSInteger )time{
//    
//    NSDate *date = [NSDate dateWithTimeIntervalSince1970:time];
//    NSDateFormatter *matter = [[NSDateFormatter alloc] init];
//    [matter setDateFormat:@"yyyy"];
//    NSString *year = [matter stringFromDate:date];
//    //NSLog(@"year------%@",year);
//    [matter setDateFormat:@"M"];
//    NSString *month = [matter stringFromDate:date];
//    //NSLog(@"month------%@",month);
//    [matter setDateFormat:@"d"];
//    NSString *day = [NSString stringWithFormat:@"%d",[[matter stringFromDate:date] intValue]];
//    //NSLog(@"day------%@",day);
//    [matter setDateFormat:@"H"];
//    NSString *shi = [matter stringFromDate:date];
//    //NSLog(@"shi------%@",shi);
//    
//    NSString *curentYear = [Utils getCurrentYear];
//    //NSLog(@"curentYear------%@",curentYear);
//    NSString *curentMonth = [Utils getCurrentMonth];
//    //NSLog(@"curentMonth------%@",curentMonth);
//    NSString *curentDay = [Utils getCurrentDay];
//    //NSLog(@"curentDay------%@",curentDay);
//    NSString *curentShi = [Utils getCurrentShi];
//    //NSLog(@"curentShi------%@",curentShi);
//    
//    if (IsEquallString(year, curentYear)) {
//        if (IsEquallString(month, curentMonth)) {
//            if (IsEquallString(day, curentDay)) {
//                if (IsEquallString(shi, curentShi)) {
//                    
//                    return @"刚刚";
//                }else{
//                    int a = [shi intValue];
//                    int b = [curentShi intValue];
//                    return [NSString stringWithFormat:@"%d小时前",b-a];
//                }
//            }else{
//                int a = [day intValue];
//                int b = [curentDay intValue];
//                int c = b-a;
//                if (c > 7) {
//                    [matter setDateFormat:@"M月d日"];
//                    return [matter stringFromDate:date];
//                }else{
//                    return [NSString stringWithFormat:@"%d天前",c];
//                }
//            }
//        }else{
//            [matter setDateFormat:@"yyyy年MM月"];
//            return [matter stringFromDate:date];
//        }
//    }else{
//       [matter setDateFormat:@"yyyy年MM月"];
//        return [matter stringFromDate:date];
//    }
//    
//}
//
//+ (NSString *)httpBase64StringFromImage:(UIImage *)image{
//    //注意选择编码的枚举
//    NSData *imageData = UIImageJPEGRepresentation(image, 0.1f);
//    NSString * imageBase64String = [imageData base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed];
//    
//    NSString * format = @"data:image/jpeg;base64,";
//    NSString * httpJpegString = [format stringByAppendingString:imageBase64String];
//    return httpJpegString;
//}
//
//
//
//
//
//@end
